/**
 * 
 */
package hu.cubussapiens.facts.query;

import hu.cubussapiens.facts.StringData;

import java.util.ArrayList;
import java.util.List;

/**
 * Select a simple literal if exists
 * 
 * @author balage
 *
 */
public class Literal implements Query {

	final String literal;
	
	public Literal(String literal) {
		this.literal = literal;
	}
	
	/* (non-Javadoc)
	 * @see hu.cubussapiens.facts.query.Query#execute()
	 */
	@Override
	public List<Long> execute(IQueryContext context) {
		List<Long> result = new ArrayList<Long>(1);
		
		StringData sd = context.getLiteral(literal);
		if (sd != null){
			if (context.canAccess(sd.getRead()));
				result.add(sd.getId());
		}
		
		return result;
	}

}
